﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace MiniFox.Data
{
    /// <summary>
    /// 数据查询对象
    /// </summary>
    /// <typeparam name="TEntity"></typeparam>
    public interface IDataQuery<TEntity> : IDataCommand<TEntity> where TEntity : class
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="expression"></param>
        /// <param name="sortFields"></param>
        /// <param name="maxRowCount"></param>
        /// <returns></returns>
        ResultSet<TEntity> Execute(Expression<Func<TEntity, bool>> expression, IDictionary<string, bool> sortFields, int? maxRowCount);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="queryable"></param>
        /// <param name="expression"></param>
        /// <param name="sortFields"></param>
        /// <param name="maxRowCount"></param>
        /// <returns></returns>
        ResultSet<TEntity> Execute(IQueryable<TEntity> queryable, Expression<Func<TEntity, bool>> expression, IDictionary<string, bool> sortFields, int? maxRowCount);
        /// <summary>
        /// 执行查询
        /// </summary>
        /// <param name="expression">条表达试</param>
        /// <param name="sortFields">排序字段</param>
        /// <returns></returns>
        ResultSet<TEntity> Execute(Expression<Func<TEntity, bool>> expression, IDictionary<string, bool> sortFields);
        /// <summary>
        /// 执行查询
        /// </summary>
        /// <param name="queryable"></param>
        /// <param name="expression"></param>
        /// <param name="sortFields"></param>
        /// <returns></returns>
        ResultSet<TEntity> Execute(IQueryable<TEntity> queryable, Expression<Func<TEntity, bool>> expression, IDictionary<string, bool> sortFields);
        /// <summary>
        /// 执行分页查询
        /// </summary>
        /// <param name="expression">条表达试</param>
        /// <param name="sortFields">排序字段</param>
        /// <param name="pageIndex">页码(从1开始)</param>
        /// <param name="pageSize">每页记录数</param>
        /// <returns></returns>
        PagedResultSet<TEntity> Execute(Expression<Func<TEntity, bool>> expression, IDictionary<string, bool> sortFields, int pageIndex, int pageSize);
        /// <summary>
        /// 执行分页查询
        /// </summary>
        /// <param name="queryable"></param>
        /// <param name="expression"></param>
        /// <param name="sortFields"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        PagedResultSet<TEntity> Execute(IQueryable<TEntity> queryable, Expression<Func<TEntity, bool>> expression, IDictionary<string, bool> sortFields, int pageIndex, int pageSize);

    }
}
